package com.es.hr.shop;

import javax.servlet.http.HttpServletRequest;

import com.es.business.area.AreaBiz;
import com.es.main.LoginUserBeen;
import com.es.util.page.PageBean;
import com.opensymphony.webwork.interceptor.ServletRequestAware;
import com.opensymphony.xwork.ActionSupport;

public class ShopSearchInitAction extends ActionSupport
implements ServletRequestAware{
	 HttpServletRequest request;

	public void setServletRequest(HttpServletRequest paramHttpServletRequest) {
		// TODO Auto-generated method stub
		this.request = paramHttpServletRequest;
	}
	
	public String execute() throws Exception{
		String result = "";
		ShopBiz shopBiz = new ShopBiz();
		LoginUserBeen userBean = (LoginUserBeen)request.getSession(false).getAttribute("loginuser");
		String role  = userBean.getLoginRole();	
		//当前角色能访问的权限组
	   String rtmAreaCode = ""; 
		if("zongbu1shiyebu".indexOf(role)>=0){
			rtmAreaCode="";//代表可以看见全部
		}else if("RTM".equals(role)){
			rtmAreaCode = userBean.getEara_code();				
		}else {//CTM&&其他
			rtmAreaCode = userBean.getEara_code();
		}				
		PageBean res = shopBiz.searchShop("", "", "", "","", 1,rtmAreaCode);
		this.request.setAttribute("pageBean", res);
		if("zongbu1shiyebu".indexOf(role)>=0){
			this.request.setAttribute("areaList", new AreaBiz().getAreaList());
		}else{
			this.request.setAttribute("areaList", new AreaBiz().getRTMAreaByCode(userBean.getEara_code()));			
		}	
		
		this.request.setAttribute("emp_role", userBean.getLoginRole());
		result = "success";
		return result;
	}

}
